//
//  Canvas.h
//  Olivia
//
//  Created by 钟昆达 on 13-3-17.
//
//

#ifndef Olivia_Canvas_h
#define Olivia_Canvas_h

#include <vector>
#include <string>

#include "../../lua_ogre/luaclassbinding.h"

#define CanvasClassName "Canvas"

class b2World;

namespace Ogre {
    class Camera;
    class SceneManager;
    class Viewport;
    class ManualObject;
}

namespace lua_ogre {
    struct LuaCamera;
}

namespace Olivia {
    
    class Tu;
    class LuaCanvas;
    class PhysicsDraw;
    
class Canvas
{
public:
    Canvas();
    ~Canvas();
    Ogre::Camera* GetCamera() const;    
    const char* GetName() const;
    void SetName(const char*);
    
    LuaCanvas* GetScriptObject() const { return m_script_obj; }
    Ogre::SceneManager* GetScene() const { return m_scn; }
    
    void Update();
protected:
    typedef std::vector<Tu*> TuVec;
    TuVec m_tu;
    Ogre::SceneManager *m_scn;
    Ogre::Camera* m_cam;
    Ogre::Viewport *m_view_port;
    std::string m_name;
    class LuaCanvas *m_script_obj;
    
    Ogre::ManualObject *m_drawer;
    b2World *m_physics_world;
    
    bool m_show_physics;
    PhysicsDraw *m_physics_drawer;
    
    friend class LuaCanvas;
};
    
struct LuaCanvas : public RefCounter
{
    LuaCanvas(Canvas*);
    ~LuaCanvas();
    const char* GetName() const;
    static const char* GetClassName();
    
    Canvas *c_obj;
    lua_ogre::LuaCamera *lua_cam;
};
    
    bool BindCanvas(lua_State*);
    
}

#endif
